#ifndef __LOG_HPP__
#define __LOG_HPP__

#include <cstdio>
#include <ctime>
#include <cstring>

/* 日志宏 */
// 日志等级
#define NORMAL 0
#define DEBUG 1
#define ERROR 2
#define LOG_LEVEL NORMAL

#define LOG(level, format, ...)                                                                 \
    do                                                                                          \
    {                                                                                           \
        if (level < LOG_LEVEL)                                                                  \
            break;                                                                              \
        time_t t = time(nullptr);                                                               \
        struct tm *ltm = localtime(&t);                                                         \
        char str_time[32] = {0};                                                                \
        strftime(str_time, 31, "%H:%M:%S", ltm);                                                \
        fprintf(stdout, "[%p:%s:%s:%d]" format "\n", (void*)pthread_self(), str_time, __FILE__, __LINE__, ##__VA_ARGS__); \
    } while (0)

#define NRL_LOG(format, ...) LOG(NORMAL, format, ##__VA_ARGS__)
#define DBG_LOG(format, ...) LOG(DEBUG, format, ##__VA_ARGS__)
#define ERR_LOG(format, ...) LOG(ERROR, format, ##__VA_ARGS__)



#endif